package com.springboot.cloud.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.springboot.cloud.entities.Comment;
import com.springboot.cloud.service.ConmmentService;

@RestController
public class ConmmentController {
	
	@Autowired
	ConmmentService cs;
	
	@ResponseBody
	@RequestMapping(value = "/getcomments/{0}", method = RequestMethod.GET)
	public List<Comment> getcomments(@PathVariable("0")int article){
		return cs.getcomments(article);
	};
	@ResponseBody
	@RequestMapping(value = "/getmycomments/{0}", method = RequestMethod.GET)
	public List<Comment> getmycomments(@PathVariable("0")int id){
		return cs.getmycomments(id);
	};
	
	@RequestMapping(value = "/addcomment", method = RequestMethod.POST)
	public boolean addcomment(@RequestBody Comment c) {
		return cs.addcomment(c);
	};
	
	@RequestMapping(value = "/comment/addlike/{id}", method = RequestMethod.GET)
	public boolean caddlike(@PathVariable("id")int id) {
		System.out.println("123");
		return cs.caddlike(id);
	};

	@RequestMapping(value = "/comment/addnolike/{id}", method = RequestMethod.GET)
	public boolean caddnolike(@PathVariable("id")int id) {
		return cs.caddnolike(id);
	};
}
